<!DOCTYPE html>
<html lang='en'>

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <!-- 准备好容器 -->
  <div id="test"></div>

  <!--引入react核心库-->
  <script src="../react.js-16/react.development.js" type="text/javascript"></script>
  <!--引入react-dom，用于支持react操作DOM-->
  <script src="../react.js-16/react-dom.development.js" type="text/javascript"></script>
  <!--引入label，用于将jsx转为js-->
  <script src="../react.js-16/babel.min.js" type="text/javascript"></script>
  <!--引入prop-types，用于对组件标签属性的限制-->
  <script src="../react.js-16/prop-types.js" type="text/javascript"></script>

  <script type="text/babel">
    //1.创建组件>
    class Login extends React.Component {
      handleSubmit = (event) => {
        event.preventDefault() //阻止表单提交
        const { user, pass } = this
        alert(`
        输入的用户名:${user.value}
        输入的密码:${pass.value}
        `)
      }

      render() {
        return (
          <form action="" onSubmit={this.handleSubmit}>
            用户名:<input ref={c => { this.user = c }} type="text" name="username" />&nbsp;
            密码:<input ref={c => { this.pass = c }} type="password" name="password" />&nbsp;
            <button>登录</button>
          </form>
        )
      }
    }
    //2.渲染组件到页面
    ReactDOM.render(<Login />, document.getElementById('test'))
  </script>
</body>

</html>